﻿//界面遮罩层
//fastCSharp.NewObject('OverIframe').ShowPath('URI');
(function(){
var OverIframe=function()
	{
	this.WaitingImage=1;
	this.PushObject();
	this.$Create('div').Css('position','absolute').Css('width,height','100%').Display(0).Id(this.GetId())
		.Html("<table id='"+this.GetId('Table')+"' cellspacing='0' cellpadding='0' border='0' width='100%' height='100%' style='background-color:#444444;'><tr height='100%'><td width='100%' height='100%' align='center'><iframe id='"+this.GetId('iframe')+"' name='"+this.GetId('iframe')+"' frameborder='0' marginwidth='0' marginheight='0' vspace='0' hspace='0' allowtransparency='true' scrolling='no'></iframe></td></tr></table>")
		.To();
	this.$Id(this.GetId('Table')).Opacity(90);
	this.MoveFunction=fastCSharp.ThisFunction(this,this.Move);
	this.FocusFunction=fastCSharp.ThisFunction(this,this.Focus);
	this.OnLoad=fastCSharp.Event();
	frames[this.GetId('iframe')].onload=fastCSharp.ThisFunction(this,this.LoadIframe);
	};
(fastCSharp.Functions.OverIframe=OverIframe).Inherit(fastCSharp.BaseFunction,{
Move:function()
	{
	var IframeId=this.GetId('iframe'),Iframe=frames[IframeId],IframeElement=this.$Id(IframeId);
	try	{
		if(this.Width==null)	IframeElement.Set('width',Iframe.document.body.scrollWidth||Iframe.document.documentElement.scrollWidth);
		if(this.Height==null)	IframeElement.Set('height',Iframe.document.body.scrollHeight||Iframe.document.documentElement.scrollHeight);
		}
	catch(e){}
	this.$Id(this.GetId()).Css('zIndex',0).Css('top',this.$ScrollTop()+'px').Css('left',this.$ScrollLeft()+'px').TopIndex();
	},
Hide:function(IsHide)
	{
	if(this.Interval)	clearTimeout(this.Interval);
	frames[this.GetId('iframe')].document.onblur=null;
	this.$Id(this.GetId()).Css('top,left','0px').Display(0);
	if((IsHide==null||IsHide)&&this.OnHide)	this.OnHide();
	},
SetHtml:function(Html)
	{
	try	{
		frames[this.GetId('iframe')].document.body.innerHTML=(arguments.length?Html:'');
		}
	catch(e){}
	},
Show:function(ReLoad)
	{
	this.Hide(0);
	var IframeId=this.GetId('iframe'),Iframe=frames[IframeId],IframeElement=this.$Id(IframeId);
	this.$Id(this.GetId()).Display(1);
	this.Move();
	this.Interval=setInterval(this.MoveFunction,500);
	if(ReLoad==null||ReLoad)
		{
		if(this.IframeCode)
			{
			try	{
				Iframe.document.body.innerHTML="<div align='center'>"+(this.WaitingImage?"<img src='/upFile/waiting.gif'><br />":'')+""+this.IframeCode+'</div>';
				}
			catch(e){
				if(this.IframeCode.substring(0,6).toLowerCase()!='<html>')	this.IframeCode='<html><body>'+this.IframeCode+'</body></html>';
				Iframe.document.open();
				Iframe.document.write(this.IframeCode);
				Iframe.document.close();
				}
			this.LoadIframe();
			}
		else if(this.IframePath)	IframeElement.Set('src',this.IframePath);
		}
	},
ShowPath:function(Path)
	{
	this.IframePath=Path;
	this.Show();
	},
ShowHtml:function(Html)
	{
	this.IframeCode=Html;
	this.Show();
	},
LoadIframe:function()
	{
	if(this.$Id(this.GetId()).Display()=='')
		{
		var IframeId=this.GetId('iframe'),Iframe=frames[IframeId];
		this.$Id(IframeId).Set('width',this.Width?this.Width:(Iframe.document.body.scrollWidth||Iframe.document.documentElement.scrollWidth))
			.Set('height',this.Height?this.Height:(Iframe.document.body.scrollHeight||Iframe.document.documentElement.scrollHeight));
		this.OnLoad();
		this.AppendInput(0);
		(this.AppendInput(1)).onfocus=(Iframe.document).onblur=this.FocusFunction;
		}
	},
AppendInput:function(InputOrder)
	{
	var Iframe=frames[this.GetId('iframe')],InputId=this.GetId('input',InputOrder),Element=Iframe.document.getElementById(InputId);
	if(Element==null)
		{
		Element=Iframe.document.createElement('input');
		Element.id=InputId;
		Element.style.position='absolute';
		Element.style.width=Element.style.height='1px';
		Element.readOnly=true;
		Iframe.document.body.appendChild(Element);
		}
	return Element;
	},
Focus:function()
	{
	frames[this.GetId('iframe')].document.getElementById(this.GetId('input',0)).focus();
	}
		});
fastCSharp.OverIframe=function()
	{
	this.OverIframe=new this.Functions.OverIframe;
	};
fastCSharp.OnLoad(fastCSharp.OverIframe,fastCSharp,1);
})();